@echo off

:set_path
set PROTOC_PATH=build\solution\Debug
set PROTOFILE_PATH=protos
set PROTOSRC_BASE=generatedProtobuf
set TARGET_CODE_DIR=TaskManagerClient\Assets\Protobuf

set PROTOCPP_PATH=%PROTOSRC_BASE%\cpp
set PROTOCSHARP_PATH=%PROTOSRC_BASE%\csharp
set PROTOJAVA_PATH=%PROTOSRC_BASE%\java
set PROTOPYTHON_PATH=%PROTOSRC_BASE%\python
set PROTORUBY_PATH=%PROTOSRC_BASE%\ruby
set PROTOJAVASCRIPT_PATH=%PROTOSRC_BASE%\javascript
set PROTOCOMMONJS_PATH=%PROTOSRC_BASE%\commonjs

:set_source_file_list
set PROTOFILES=%PROTOFILE_PATH%\base.proto
set PROTOFILES=%PROTOFILES% %PROTOFILE_PATH%\TaskManagerSystem\*.proto

:create_noexist_path
rmdir /S /Q %PROTOSRC_BASE%
mkdir %PROTOSRC_BASE%
mkdir %PROTOCPP_PATH%
mkdir %PROTOCSHARP_PATH%
mkdir %PROTOJAVA_PATH%
mkdir %PROTOPYTHON_PATH%
mkdir %PROTORUBY_PATH%
mkdir %PROTOJAVASCRIPT_PATH%
mkdir %PROTOCOMMONJS_PATH%

:execute_protoc
%PROTOC_PATH%\protoc.exe -I=%PROTOFILE_PATH% --cpp_out=%PROTOCPP_PATH% %PROTOFILES%
%PROTOC_PATH%\protoc.exe -I=%PROTOFILE_PATH% --csharp_out=%PROTOCSHARP_PATH% %PROTOFILES%
%PROTOC_PATH%\protoc.exe -I=%PROTOFILE_PATH% --java_out=%PROTOJAVA_PATH% %PROTOFILES%
%PROTOC_PATH%\protoc.exe -I=%PROTOFILE_PATH% --python_out=%PROTOPYTHON_PATH% %PROTOFILES%
%PROTOC_PATH%\protoc.exe -I=%PROTOFILE_PATH% --ruby_out=%PROTORUBY_PATH% %PROTOFILES%
::%PROTOC_PATH%\protoc.exe -I=%PROTOFILE_PATH% --js_out=library=aaserver_proto,binary:%PROTOJAVASCRIPT_PATH% %PROTOFILES%
::%PROTOC_PATH%\protoc.exe -I=%PROTOFILE_PATH% --js_out=import_style=commonjs,binary:%PROTOCOMMONJS_PATH% %PROTOFILES%

:copy csharp code
rmdir /S /Q %TARGET_CODE_DIR%
mkdir %TARGET_CODE_DIR%
xcopy %PROTOCSHARP_PATH% %TARGET_CODE_DIR% /C /E /Y

:end
pause